<?php
class MaterialInfoList extends AppModel
{
    public $name = 'MaterialInfoList';
    public $primaryKey = '_id';

    public function set_all_data($_db_name, $_data)
    {
        $this->useDbConfig = $_db_name['game_data'];
        $this->deleteAll(array('_id not' => null));

        foreach($_data as $action) {
            $this->create();
            if(!$this->save($action))
                return false;
        }
        return true;
    }

    public function id_check($_db_name, $_id)
    {
        $this->useDbConfig = $_db_name['game_data'];
        $params = array(
            'conditions' => array(
                'Id' => $_id
            )
        );

        $data = $this->find('first', $params);

        $result['id'] = $_id;
        $result['data'] = $data;

        return $result;
    }
}